package com.education.welco.service.impl;

import com.education.welco.mapper.OrderAnswerMapper;
import com.education.welco.mapper.OrderUserPaperMapper;
import com.education.welco.pojo.OrderPaper;
import com.education.welco.pojo.OrderUserPaper;
import com.education.welco.pojo.vo.ClassPaper;
import com.education.welco.pojo.vo.WholePaperInfoAppVO;
import com.education.welco.service.OrderUserPaperService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderUserServiceImpl implements OrderUserPaperService {

    @Autowired
    private OrderUserPaperMapper orderUserPaperMapper;

    @Autowired
    private OrderAnswerMapper orderAnswerMapper;

    @Override
    public List<OrderUserPaper> OrderUserPaperlist(Integer paper) {
        return orderUserPaperMapper.OrderUserPaperlist(paper);
    }

    @Override
    public List<OrderUserPaper> OrderUserPaperlist3(Integer paper) {
        return orderUserPaperMapper.OrderUserPaperlist3(paper);
    }

    @Override
    public List<OrderUserPaper> OrderUserPaperlist1(Integer userId) {
        return orderUserPaperMapper.OrderUserPaperlist1(userId);
    }

    @Override
    public int InsertOrderPaper(OrderUserPaper orderUserPaper) {
        return orderUserPaperMapper.InsertOrderPaper(orderUserPaper);
    }

//    @Override
//    public List<OrderUserPaper> selectlist(Integer userId) {
//        return orderUserPaperMapper.selectlist(userId);
//    }

    @Override
    public OrderUserPaper SelectOrderUserPaper(Integer paperId, Integer userId) {
        return orderUserPaperMapper.SelectOrderUserPaper(paperId, userId);
    }

    @Override
    public OrderUserPaper SelectOrderUserPaperForInfo(Integer paperId, Integer userId) {
        return orderUserPaperMapper.SelectOrderUserPaperForInfo(paperId, userId);
    }

    @Override
    public OrderUserPaper SelectOrderUserPaper1(Integer paperId, Integer userId) {
        return orderUserPaperMapper.SelectOrderUserPaper1(paperId, userId);
    }

    @Override
    public int update(OrderUserPaper orderUserPaper) {
        return orderUserPaperMapper.update(orderUserPaper);
    }

    @Override
    public int update2(OrderUserPaper orderUserPaper) {
        //new OrderAnswer()
        //orderAnswerMapper.updateOrderAnswer()
        return orderUserPaperMapper.update2(orderUserPaper);
    }

    @Override
    public int delete(Integer paperId, Integer userId) {
        return orderUserPaperMapper.delete(paperId, userId);
    }

    @Override
    public List<OrderUserPaper> OrderUserPaperlist2(Integer userId, Integer paperId) {
        return orderUserPaperMapper.OrderUserPaperlist2(userId, paperId);
    }

    @Override
    public Integer selectCommitPaperNum(Integer paperId) {
        return orderUserPaperMapper.selectCommitPaperNum(paperId);
    }

    @Override
    public List<ClassPaper> classPaperList(Integer paperId, Integer classId, Integer readState, Integer pageNum, Integer pageSize) {
        if (pageNum != null && pageSize != null) {
            PageHelper.startPage(pageNum, pageSize);
        }
        return orderUserPaperMapper.classPaperList(paperId, classId, readState);
    }

    @Override
    public String selectTeaIdByCourseId(Integer courseId) {
        return orderUserPaperMapper.selectTeaIdByCourseId(courseId);
    }

    /**
     * 答题完毕后学生查看答题详情
     *
     * @param paperId 试卷id
     * @param stuId   学生用户id
     * @return
     */
    @Override
    public OrderUserPaper exitQuerypaperInfo(Integer paperId, Integer stuId) {
        return orderUserPaperMapper.exitQuerypaperInfo(paperId, stuId);
    }

    /**
     * 首页成绩排行  班级与试卷
     *
     * @param paperId
     * @param teaId
     * @param classId
     * @return
     */
    @Override
    public List<OrderUserPaper> homeScoreQueryForTea(Integer teaId, Integer paperId, Integer classId) {
        return orderUserPaperMapper.homeScoreQueryForTea(teaId, paperId, classId);
    }

    /**
     * 老师端首页成绩排行 查找班级下的试卷列表
     */
    @Override
    public List<OrderPaper> selectPaperBoxByClassId(Integer classId) {
        return orderUserPaperMapper.selectPaperBoxByClassId(classId);
    }

    @Override
    public List<WholePaperInfoAppVO> wholePaperInfo(Integer paperId, String likeName) {
        return orderUserPaperMapper.wholePaperInfo(paperId,likeName);
    }

    @Override
    public OrderUserPaper selectorderUserPaperById(Integer stuPaperId) {
        return orderUserPaperMapper.selectorderUserPaperById(stuPaperId);
    }
}
